home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / Mac OS USB DDK_v1.0.1 / Interfaces / UniversalHIDModule.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-03  |  4.8 KB  |  158 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        UniversalHIDModule.h
  3.  
  4.     Contains:    This describes the interface a higher level part of the OS uses
  5.                 to talk with a UniversalHIDModule, and the way to implement
  6.                 a UniversalHIDModule compliant HID module.
  7.                 
  8.                 This file is checked in in addition to UniversalHIDModule.i, see the
  9.                 comments _there_ on how to make changes to this file!
  10.                 
  11.                 DO NOT CHANGE THIS FILE W/O CHANGING UniversalHIDModule.i FIRST
  12.  
  13.     Version:    xxx put version here xxx
  14.  
  15.     Copyright:    © 1998 by Apple Computer, Inc., all rights reserved.
  16.  
  17. */
  18. /* We are not USB specific, but we share many definitions with the USB spec*/
  19. #ifndef __UNIVERSALHIDMODULE__
  20. #define __UNIVERSALHIDMODULE__
  21.  
  22. #ifndef __MACTYPES__
  23. #include <MacTypes.h>
  24. #endif
  25. #ifndef __USB__
  26. #include <USB.h>
  27. #endif
  28.  
  29.  
  30.  
  31. #if PRAGMA_ONCE
  32. #pragma once
  33. #endif
  34.  
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38.  
  39. #if PRAGMA_IMPORT
  40. #pragma import on
  41. #endif
  42.  
  43. #if PRAGMA_STRUCT_ALIGN
  44.     #pragma options align=mac68k
  45. #elif PRAGMA_STRUCT_PACKPUSH
  46.     #pragma pack(push, 2)
  47. #elif PRAGMA_STRUCT_PACK
  48.     #pragma pack(2)
  49. #endif
  50.  
  51. typedef UInt32                             UHIDModuleConnectionID;
  52. /* FunctionPtr to be called when inturrupt occurs*/
  53. typedef CALLBACK_API_C( void , UHIDInterruptProcPtr )(void *theData, UInt32 refcon);
  54. /* FunctionPtr definitions for UniversalHIDModule dispatch table*/
  55. typedef CALLBACK_API_C( OSStatus , UHIDGetDeviceInfoProcPtr )(UInt32 inInfoSelector, void *outInfo);
  56. typedef CALLBACK_API_C( OSStatus , UHIDGetHIDDescriptorProcPtr )(UInt32 inDescriptorType, UInt32 inDescriptorIndex, UInt32 *ioBufferSize, void *outBuffer);
  57. typedef CALLBACK_API_C( OSStatus , UHIDClaimDeviceProcPtr )(UHIDModuleConnectionID *outConnectionID, UInt32 reserved);
  58. typedef CALLBACK_API_C( OSStatus , UHIDReleaseDeviceProcPtr )(UHIDModuleConnectionID inConnectionID);
  59. typedef CALLBACK_API_C( OSStatus , UHIDInstallInterruptProcPtr )(UHIDModuleConnectionID inConnectionID, UHIDInterruptProcPtr inInterruptProc, UInt32 inRefcon);
  60. typedef CALLBACK_API_C( OSStatus , UHIDControlDeviceProcPtr )(UHIDModuleConnectionID inConnectionID, UInt32 inControlSelector, void *ioControlData);
  61.  
  62. enum {
  63.     kCurrentDispatchTableVersion = 5,
  64.     kOldestCompatableDispatchTableVersion = 5
  65. };
  66.  
  67. /*
  68.    UHIDModuleDispatchTable is exported by the HIDModule's PEF container
  69.    dispatchTableCurrentVersion is kCurrentDispatchTableVersion
  70.    dispatchTableOldestVersion is kOldestCompatableDispatchTableVersion
  71.           (the oldest built client using this API that this UHIDModule will work with)
  72.    venderID is who wrote this UniversalHIDModule (hi word of 0 and USB venderID is valid)
  73. */
  74.  
  75. struct UHIDModuleDispatchTableStruct {
  76.     UInt16                             dispatchTableCurrentVersion;
  77.     UInt16                             dispatchTableOldestVersion;
  78.     UInt32                             venderID;
  79.     UInt32                             venderSpecific;
  80.     UInt32                             reserved;
  81.     UHIDGetDeviceInfoProcPtr         pUHIDGetDeviceInfo;
  82.     UHIDClaimDeviceProcPtr             pUHIDClaimDevice;
  83.     UHIDReleaseDeviceProcPtr         pUHIDReleaseDevice;
  84.     UHIDInstallInterruptProcPtr     pUHIDInstallInterrupt;
  85.     UHIDControlDeviceProcPtr         pUHIDControlDevice;
  86.     UHIDGetHIDDescriptorProcPtr     pUHIDGetHIDDescriptor;
  87. };
  88. typedef struct UHIDModuleDispatchTableStruct UHIDModuleDispatchTableStruct;
  89.  
  90. typedef UHIDModuleDispatchTableStruct     UHIDModuleDispatchTable;
  91. typedef UHIDModuleDispatchTableStruct *    UHIDModuleDispatchTablePtr;
  92. /* the prototypes for the actual functions in the UHIDModule follow*/
  93. EXTERN_API_C( OSStatus )
  94. UHIDGetDeviceInfo                (UInt32                 inInfoSelector,
  95.                                  void *                    outInfo);
  96.  
  97. EXTERN_API_C( OSStatus )
  98. UHIDGetHIDDescriptor            (UInt32                 inDescriptorType,
  99.                                  UInt32                 inDescriptorIndex,
  100.                                  UInt32 *                ioBufferSize,
  101.                                  void *                    outBuffer);
  102.  
  103. /* Claim and release are a way to insure that only one client is connected*/
  104. EXTERN_API_C( OSStatus )
  105. UHIDClaimDevice                    (UHIDModuleConnectionID * outConnectionID,
  106.                                  UInt32                 reserved);
  107.  
  108. EXTERN_API_C( OSStatus )
  109. UHIDReleaseDevice                (UHIDModuleConnectionID  inConnectionID);
  110.  
  111. EXTERN_API_C( OSStatus )
  112. UHIDInstallInterrupt            (UHIDModuleConnectionID  inConnectionID,
  113.                                  UHIDInterruptProcPtr     inInterruptProc,
  114.                                  UInt32                 inRefcon);
  115.  
  116. EXTERN_API_C( OSStatus )
  117. UHIDControlDevice                (UHIDModuleConnectionID  inConnectionID,
  118.                                  UInt32                 inControlSelector,
  119.                                  void *                    ioControlData);
  120.  
  121. /* these are the constants to be passed to UHIDControlDevice*/
  122.  
  123. enum {
  124.     kUHIDRemoveInterruptHandle    = 0,
  125.     kUHIDVenderSpecificControlStart = 0x00010000
  126. };
  127.  
  128. /* these are the constants to be passed to UHIDGetDeviceInfo*/
  129.  
  130. enum {
  131.     kUHIDGetVenderID            = 0,
  132.     kUHIDGetProductID            = 1,
  133.     kUHIDGetMaxPacketSize        = 2,
  134.     kUHIDVenderSpecificGetInfoStart = 0x00010000
  135. };
  136.  
  137.  
  138. #if PRAGMA_STRUCT_ALIGN
  139.     #pragma options align=reset
  140. #elif PRAGMA_STRUCT_PACKPUSH
  141.     #pragma pack(pop)
  142. #elif PRAGMA_STRUCT_PACK
  143.     #pragma pack()
  144. #endif
  145.  
  146. #ifdef PRAGMA_IMPORT_OFF
  147. #pragma import off
  148. #elif PRAGMA_IMPORT
  149. #pragma import reset
  150. #endif
  151.  
  152. #ifdef __cplusplus
  153. }
  154. #endif
  155.  
  156. #endif /* __UNIVERSALHIDMODULE__ */
  157.  
  158.